//
//  BQCycleViewCell.m
//  BeeQuick
//
//  Created by mac on 16/11/20.
//  Copyright © 2016年 six_group. All rights reserved.
//

#import "BQCycleViewCell.h"
#import "SDCycleScrollView.h"
#import "BQActRowModel.h"
@interface BQCycleViewCell()<SDCycleScrollViewDelegate>

@property(weak,nonatomic)SDCycleScrollView *sdView;

@end
@implementation BQCycleViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    //轮播界面的搭建
    
    SDCycleScrollView *cyclePicView = [SDCycleScrollView cycleScrollViewWithFrame:self.bounds delegate:self placeholderImage:nil];
    
    
    [self.contentView addSubview:cyclePicView];
    
    
    [cyclePicView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
        make.size.mas_equalTo(self.bounds.size);
    }];
    
    self.sdView = cyclePicView;
    
    //MARK: - 设置分页控制器的位置.
    self.sdView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    // 当前分页控件小圆标颜色
    
    self.sdView.currentPageDotColor = [UIColor cz_colorWithHex:0xfdd431];
    
//    其他分页控件小圆标颜色
    
    self.sdView.pageDotColor = [UIColor cz_colorWithHex:0xe0e0e0];
    
    //点击事件的回传
//    self.sdView.clickItemOperationBlock = @property (nonatomic, copy) void (^clickItemOperationBlock)(NSInteger currentIndex);

    self.sdView.clickItemOperationBlock = ^(NSInteger currentIndex){
        NSLog(@"轮播第%zd张图的点击",currentIndex);
        
        //取出改图的model 准备跳转//或者回调到控制器进行跳转 // 代理都行
        
//        BQHomeFocusModel *model = self.focusModelArr[currentIndex];
//        
//        NSLog(@"图片名字是%@",model.name);
        
        if([self.delegate respondsToSelector:@selector(BQCycleViewCell:withPicIndex:)])
        {
            [self.delegate BQCycleViewCell:self withPicIndex:currentIndex];
        }
    
        
    };

}
- (void)setFocusModelArr:(NSArray<BQActRowModel *> *)focusModelArr
{
    _focusModelArr = focusModelArr;
    
    NSMutableArray *picArr = [NSMutableArray array];
    for (BQActRowModel *model  in focusModelArr) {
        
        [picArr addObject:model.activity.img];
        
    }
    
    self.sdView.imageURLStringsGroup = picArr;

    
}




@end
